home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Languguage OS 2
/
Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO
/
language
/
embedded
/
develop
/
libsrc11.arc
/
DIVS.S
< prev
next >
Wrap
Text File
|
1989-04-27
|
1KB
|
57 lines
******************************************************************************
* divs.s 3.1 11/12/84
*
* 68HC11 CROSS C COMPILER RUN-TIME LIBRARY
*
* (c) Copyright 1984, Motorola, Inc.
*
* FUNCTION NAME: .divs
*
* ACTION: Calculate the quotient of two 8-bit signed integers.
*
* REGISTERS AND STACK:
*
* ON ENTRY: X: FP (frame pointer)
* B: Dividend
* A: Divisor
*
* STACK: Return Address
* SP:
*
* ON EXIT: X: FP
* Y: Preserved
* B: Quotient
*
* STACK: Previous Contents
* SP:
*
******************************************************************************
psct
xdef .divs
.divs:
pshx save FP
psha save sign of divisor
tsta is divisor > 0?
bpl *+3 yes
nega no..negate
psha copy..
clra ..divisor
psha ..to
pulx ..X
tstb is dividend > 0?
bpl div1 yes
negb no..negate and..
pula ..complement
coma ..sign bit
psha
clra
div1: idiv do division D/X
xgdx get quotient
pula recover sign
tsta is sign positive?
bpl *+3 yes
negb no..negate quotient
pulx restore FP
rts return
end